package com.future.direction.common.util;

import android.app.Activity;
import android.graphics.Color;
import android.support.v4.app.FragmentActivity;
import android.view.View;

import com.bigkoo.pickerview.OptionsPickerView;
import com.future.direction.R;
import com.future.direction.interfaces.SelecteListener;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhp on 2019/6/12
 */
public class PopupCurrency {

    OptionsPickerView pvOptions;

    public PopupCurrency(FragmentActivity activity, SelecteListener selecteListener) {
        pvOptions = initOptionPicker(activity, selecteListener);
    }

    private OptionsPickerView initOptionPicker(Activity activit, SelecteListener selecteListener) {
        OptionsPickerView pvOptions = new OptionsPickerView.Builder(activit, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                selecteListener.selectPosition(options1);
            }
        })
                .setTitleBgColor(Color.WHITE)
                .setCancelColor(Color.BLACK)
                .setSubmitColor(Color.BLACK)
                .setContentTextSize(14)//设置滚轮文字大小
                .setDividerColor(Color.LTGRAY)//设置分割线的颜色
                .setLineSpacingMultiplier(12f)
                .setSelectOptions(0, 0, 0)//默认选中项
                .setBgColor(Color.WHITE)
                .setCancelColor(Color.GRAY)
                .setSubmitColor(Color.GRAY)
                .setTextColorOut(Color.BLACK)
                .setTextColorCenter(Color.BLACK)
                .isCenterLabel(false) //是否只显示中间选中项的label文字，false则每项item全部都带有label。
                .setBackgroundId(0x66000000) //设置外部遮罩颜色
                .build();
        return pvOptions;

    }


    public void setData(List<String> datas) {
        /*if (null != pvOptions) {
            pvOptions.setPicker(datas);
        }*/
        List data = new ArrayList<String>();
        data.add("USDT");
        data.add(UIUtil.getString(R.string.app_name));
        if (null != pvOptions) {
            pvOptions.setPicker(data);
        }
    }

    public void show(int position) {
        if (null != pvOptions) {
            pvOptions.setSelectOptions(position);
            pvOptions.show();
        }
    }
}
